package com.woniuxy.utils;

import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Set;

public class JedisUtils {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("localhost",6379);
        String foo = jedis.auth("foo");
        jedis.set("myjedis","马宇航");
        System.out.println(jedis.get("myjedis"));
        jedis.hset("myjedishash","myname","蒲旭波");
        System.out.println(jedis.hget("myjedishash", "myname"));
        jedis.lpush("mypush","a","b","c");
        List<String> mypush = jedis.lrange("mypush", 0, -1);
        for (String s : mypush) {
            System.out.println(s);
        }
        jedis.sadd("myset11","aaa","bbb","sss");
        Set<String> myset11 = jedis.smembers("myset11");
        for (String s : myset11) {
            System.out.println(s);

        }
        jedis.zadd("myzset",50,"没及格");
        jedis.zadd("myzset",60,"运气好");
        jedis.zadd("myzset",90,"你牛逼");
        Set<String> myzset = jedis.zrange("myzset", 0, -1);
        for (String s : myzset) {
            System.out.println(s);
        }

        jedis.close();
    }
}
